﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QLNH_DAL_WS
{
    public class InfoDAO
    {
        public InfoDTO GetInfo()
        {
            RestaurantManagementDataContext data = new RestaurantManagementDataContext();

            var result = (from info in data.INFOs
                          select info).First();

            return new InfoDTO(result.Name, result.Address, result.PhoneNumber, result.Description); ;
        }

        public bool UpdateInfo(InfoDTO infoDTO)
        {
            RestaurantManagementDataContext data = new RestaurantManagementDataContext();

            var result = (from info in data.INFOs
                          where info.ID.Equals("INF000")
                          select info).First();
            result.Name = infoDTO.Name;
            result.Address = infoDTO.Address;
            result.PhoneNumber = infoDTO.PhoneNumber;
            result.Description = infoDTO.Description;

            try
            {
                data.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}